package cn.dust.design.pattern.creational.simplefactory;

import java.lang.reflect.InvocationTargetException;

/**
 * @Author: dust
 * @Date: 2019/11/25 13:34
 */
public class HeroFactory {

    public Hero chuansong(Class c){
        Hero hero=null;
        try {
            hero=(Hero)Class.forName(c.getName()).getDeclaredConstructor().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return hero;
    }


}
